-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(macOS): Replace core-graphics to prevent private api usage #165
Conversation
Reviewer's Guide by SourceryThis PR replaces the core-graphics crate with a local copy to prevent private API usage on macOS. The implementation copies the entire core-graphics crate into the project and patches it to use the local version instead of the crates.io version. Class diagram for the new core-graphics implementationclassDiagram
class CGEvent {
+type_id() CFTypeID
+new(source: CGEventSource) Result<CGEvent, ()>
+new_keyboard_event(source: CGEventSource, keycode: CGKeyCode, keydown: bool) Result<CGEvent, ()>
+new_mouse_event(source: CGEventSource, mouse_type: CGEventType, mouse_cursor_position: CGPoint, mouse_button: CGMouseButton) Result<CGEvent, ()>
+post(tap_location: CGEventTapLocation)
+location() CGPoint
+set_flags(flags: CGEventFlags)
+get_flags() CGEventFlags
+set_type(event_type: CGEventType)
+get_type() CGEventType
+set_string(string: &str)
+get_integer_value_field(field: CGEventField) i64
+set_integer_value_field(field: CGEventField, value: i64)
+get_double_value_field(field: CGEventField) f64
+set_double_value_field(field: CGEventField, value: f64)
}
class CGContext {
+type_id() CFTypeID
+create_bitmap_context(data: Option<*mut c_void>, width: size_t, height: size_t, bits_per_component: size_t, bytes_per_row: size_t, space: &CGColorSpace, bitmap_info: u32) CGContext
+data() &mut [u8]
}
class CGDisplay {
+new(id: CGDirectDisplayID) CGDisplay
+main() CGDisplay
+null_display() CGDisplay
+bounds() CGRect
+display_mode() Option<CGDisplayMode>
+begin_configuration() Result<CGDisplayConfigRef, CGError>
+cancel_configuration(config_ref: &CGDisplayConfigRef) Result<(), CGError>
+complete_configuration(config_ref: &CGDisplayConfigRef, option: CGConfigureOption) Result<(), CGError>
+configure_display_with_display_mode(config_ref: &CGDisplayConfigRef, display_mode: &CGDisplayMode) Result<(), CGError>
+configure_display_origin(config_ref: &CGDisplayConfigRef, x: i32, y: i32) Result<(), CGError>
+configure_display_mirror_of_display(config_ref: &CGDisplayConfigRef, master: &CGDisplay) Result<(), CGError>
+image() Option<CGImage>
+screenshot(bounds: CGRect, list_option: CGWindowListOption, window_id: CGWindowID, image_option: CGWindowImageOption) Option<CGImage>
+screenshot_from_windows(bounds: CGRect, windows: CFArray, image_option: CGWindowImageOption) Option<CGImage>
+window_list_info(option: CGWindowListOption, relative_to_window: Option<CGWindowID>) Option<CFArray>
+is_active() bool
+is_always_in_mirror_set() bool
+is_asleep() bool
+is_builtin() bool
+is_in_hw_mirror_set() bool
+is_in_mirror_set() bool
+is_main() bool
+is_online() bool
+uses_open_gl_acceleration() bool
+is_stereo() bool
+mirrors_display() CGDirectDisplayID
+primary_display() CGDirectDisplayID
+rotation() f64
+screen_size() CGSize
+serial_number() u32
+unit_number() u32
+vendor_number() u32
+model_number() u32
+pixels_high() u64
+pixels_wide() u64
+active_displays() Result<Vec<CGDirectDisplayID>, CGError>
+active_display_count() Result<u32, CGError>
+hide_cursor() Result<(), CGError>
+show_cursor() Result<(), CGError>
+move_cursor_to_point(point: CGPoint) Result<(), CGError>
+warp_mouse_cursor_position(point: CGPoint) Result<(), CGError>
+associate_mouse_and_mouse_cursor_position(connected: bool) Result<(), CGError>
}
class CGFont {
+type_id() CFTypeID
+from_data_provider(provider: CGDataProvider) Result<CGFont, ()>
+from_name(name: &CFString) Result<CGFont, ()>
+create_copy_from_variations(vars: &CFDictionary<CFString, CFNumber>) Result<CGFont, ()>
+postscript_name() CFString
+get_glyph_b_boxes(glyphs: &[CGGlyph], bboxes: &mut [CGRect]) bool
+get_glyph_advances(glyphs: &[CGGlyph], advances: &mut [c_int]) bool
+get_units_per_em() c_int
+copy_table_tags() CFArray<u32>
+copy_table_for_tag(tag: u32) Option<CFData>
+copy_variations() Option<CFDictionary<CFString, CFNumber>>
+copy_variation_axes() Option<CFArray<CFDictionary<CFString, CFType>>>
}
class CGImage {
+new(width: size_t, height: size_t, bits_per_component: size_t, bits_per_pixel: size_t, bytes_per_row: size_t, colorspace: &CGColorSpace, bitmap_info: u32, provider: &CGDataProvider, should_interpolate: bool, rendering_intent: u32) Self
+type_id() CFTypeID
}
class CGDataProvider {
+type_id() CFTypeID
+from_buffer<T: AsRef<[u8]> + Sync + Send>(buffer: Arc<T>) Self
+from_slice(buffer: &[u8]) Self
+from_custom_data(custom_data: Box<Box<dyn CustomData>>) Self
}
class CGPath {
+from_rect(rect: CGRect, transform: Option<&CGAffineTransform>) CGPath
+type_id() CFTypeID
+apply<'a, F>(&'a self, mut closure: &'a F) where F: FnMut(CGPathElementRef<'a>)
}
class CGColorSpace {
+type_id() CFTypeID
+create_with_name(name: CFStringRef) Option<CGColorSpace>
+create_device_rgb() CGColorSpace
+create_device_gray() CGColorSpace
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @XMLHexagram - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Summary by Sourcery
New Features: